package Operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class FindOperation implements IOperation{
    @Override
    public void work(BookList books) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("查找图书!");
        System.out.println("请输入书名: ");
        String name=scanner.next();
        for (int i=0;i<books.getUserSize();i++) {
            Book book= books.getBooks(i);//将返回的引用给book
            if(book.getName().equals(name))//用book去调用Book类的getName
            {
                System.out.println(books.getBooks(i));
                return;
            }
        }
        System.out.println("没有找到该图书!");
    }

}

